<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/5/30
  Time: 9:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap-3.4.1-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap-3.4.1-dist/css/bootstrap-theme.min.css">
<html>
<head>
    <title>商品</title>

    <script>
        function del() {
            if (confirm("确认删除吗?")==true){
                return true;
            }else {
                return false;
            }
        }
    </script>
</head>
<body>
    <h2> 当前登录的用户: ${sessionScope.user}</h2>
    <h2> 商品列表 </h2>
    <form action="">
        <input type="text" placeholder="请输入搜索的名称">
        <button>搜索</button>
    </form>
    <a href="${pageContext.request.contextPath}/goods/add.jsp"
       class="btn btn-primary btn-sm active" role="button">增加商品</a>
    <table border="1">
        <tr>
            <td>选择</td>
            <td> 编号</td>
            <td> 商品名称</td>
            <td> 价格 </td>
            <td> 操作 </td>

        </tr>

        <c:forEach items="${li}" var="good" varStatus="status">
            <tr>
                <td><input type="checkbox"> </td>
                <td width="50px"> ${status.count}</td>
                <td width="50px">${good.name}</td>
                <td width="50px"> ${good.price} </td>
                <td width="50px">
                    <a href="${pageContext.request.contextPath}/detailServlet?id=${good.id}"> 详情</a>
                    <a href="${pageContext.request.contextPath}/editUIServlet?id=${good.id}"> 修改</a>
<%--                    <a href="${pageContext.request.contextPath}/deleteServlet?id=${good.id}" onclick="javascript:return del()"> 删除</a>--%>
                    <a href="${pageContext.request.contextPath}/deleteServlet?id=${good.id}" onclick="javascript:return confirm('确认删除吗?')"> 删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</body>
</html>


<%--
1、el表达式能取哪些值： 所有域attribute里的值：request 、 session 、servletContext, page

--%>